<?php
/**
 * Nweb Editor Application
 *
 * This script is protected by copyright. It's use, copying, modification
 * and distribution without written consent of the author is prohibited.
 *
 * @category    public
 * @package     pl.nweb.editor
 * @author      Krzysztof Kardasz <krzysztof.kardasz@gmail.com>
 * @copyright   Copyright (c) 2011 Krzysztof Kardasz
 * @license     http://www.gnu.org/licenses/lgpl-3.0.txt  GNU Lesser General Public
 * @version     1.0 $Id$
 * @link        http://code.google.com/p/nweb-editor/
 * @link        http://editor.nweb.pl
 */

/* Analiza wydajności */
$time   = microtime(true);
$memory = memory_get_usage();
register_shutdown_function('__shutdown');
function __shutdown() {
    global $time, $memory;
    $endTime   = microtime(true);
    $endMemory = memory_get_usage();

    $generate    = round(($endTime-$time), 4);
    $memoryUsage = round(($endMemory-$memory)/1024/1024, 3);

    printf('<!--[nweb.benchmark] %s time: %f s memory: %f MB -->',  date('Y-m-d H:i:s'), $generate, $memoryUsage);

    $fp = fopen(__DIR__ . '/benchmark.log', 'a');
    $uri = (isset($_SERVER['REQUEST_URI'])) ? $_SERVER['REQUEST_URI'] : '';
    fwrite($fp, sprintf(('%s:' . "\t" . ' %s time: %f s memory: %f MB' . "\n"), date('Y-m-d H:i:s'), $uri, $generate, $memoryUsage));
    fclose($fp);
}

/** @see /pl/nweb/framework/Application **/
require_once '../src/pl/nweb/framework/application.php';

use pl\nweb\framework\Application;

/* Przygotowanie aplikacji */
$app = new Application (array(
    Application::PARAM_APPLICATION_PATH => realpath(__DIR__ . '/../app'),
    Application::PARAM_ENV_HOST         => 'configs/final/hosts.env.php',
    Application::PARAM_ENV_GETOPT       => 'env'
));

/* Uruchomienie aplikacji */
$app->run();